home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BEERSRC.ZIP / SUPPORT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-27  |  2.0 KB  |  102 lines

  1.  
  2. // module 'SUPPORT.C'
  3. // [c] copyright by ALPHA-HELIX 1993
  4.  
  5. // Turn of unwanted warnings.
  6. #pragma warn -stu
  7.  
  8. #pragma hdrstop
  9. #include <dos.h>
  10. #include <fcntl.h>
  11. #include <io.h>
  12. #include <sys\stat.h>
  13.  
  14. #include "xmode.h"
  15. #include "baller.h"
  16. #include "sound.h"
  17.  
  18. /*------------------------------------------------------
  19. Function: setspeed
  20.  
  21. Description: Sets the speed of the timer.
  22.          0x0000 is about 18 ticks per second.
  23.          0x8000 "    "   36   "    "    "   .
  24. ------------------------------------------------------*/
  25. void setspeed(unsigned speed)
  26. {
  27.    outportb(0x43, 0x36);
  28.    outportb(0x40, speed & 0xff);
  29.    outportb(0x40, speed >> 8);
  30.    inportb(0x61);
  31.  
  32. }
  33.  
  34.  
  35.  
  36. void waitforkey(void)
  37. {
  38.    while (pressedkeys);
  39.    while (!pressedkeys);
  40. }
  41.  
  42. int waitdelayedkey(int count)
  43. {
  44.    while (!pressedkeys && --count) waitfortick();
  45.    return (count) ? 1 : 0;
  46. }
  47.  
  48.  
  49. void writetext(int x, int y, const char *s, struct sprstrc *font)
  50. {
  51.    int   i;
  52.    int   xs;
  53.  
  54.    xs = font->xs;
  55.    i = 0;
  56.    while (s[i] != 0) {
  57.       putspritedirect(font, x, y, s[i++] - ' ');
  58.       x += xs;
  59.    }
  60.  
  61. }
  62.  
  63.  
  64. void writenumber(int x, int y, long number, struct sprstrc *font)
  65. {
  66.    int j, xs, i = 0;
  67.    int zahl;
  68.  
  69.    xs = font->xs;
  70.    for(j = 0; j < 2; j++){
  71.       zahl = number % 10;
  72.       number /= 10;
  73.       putspritedirect(font, x, y, 16 + zahl);
  74.       x -= xs;
  75.    }
  76.    putspritedirect(font, x, y, '.'-' ');
  77.    for(; j < 10; j++){
  78.       x -= xs;
  79.       zahl = number % 10;
  80.       number /= 10;
  81.       if(zahl != 0 || j == 2){
  82.      putspritedirect(font, x, y, 16 + zahl);
  83.      if(i!=0) for(; i > 0; i--) putspritedirect(font, x+i*xs, y, 16);
  84.      i = 0;
  85.       }else{
  86.      i ++;
  87.       }
  88.    }
  89. }
  90.  
  91. void killallbuddies(void)
  92. {
  93.    int   i;
  94.  
  95.    for (i = 0; i < MAXARMS; i++) _arm[i].object = -1;
  96.    for (i = 0; i < MAXFOES; i++) _foe[i].object = -1;
  97.    for (i = 0; i < MAXSHOTS; i++) _shot[i].object = -1;
  98.    for (i = 0; i < MAXEXPLS; i++) _expl[i].object = -1;
  99.  
  100. }
  101.  
  102.